﻿# -*- coding: utf-8 -*-

import json
import datetime
import decimal
from bson import ObjectId

'''
    把数据库查询到的数据转换为json格式的工具类
'''


class MyJsonEncoder(json.JSONEncoder):
    '''
        重写构造json类，对日期等格式进行特殊处理
    '''

    def default(self, obj):
        if isinstance(obj, datetime.datetime):
            return obj.strftime('%Y-%m-%d %H:%M:%S')
        elif isinstance(obj, datetime.date):
            return obj.strftime('%Y-%m-%d')
        elif isinstance(obj, decimal.Decimal):
            return str(obj)
        elif isinstance(obj, ObjectId):
            return str(obj)
        else:
            return json.JSONEncoder.default(self, obj)


class Table2Json(object):
    '''
        工具类，把MySQL数据库获取的数据转换为JSON格式
    '''

    @staticmethod
    def admin_list_to_json(lists):
        """
        把从admin表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['adminId'] = row[0]
            result['roleId'] = row[1]
            result['roleType'] = row[2]
            result['adminName'] = row[3]
            result['adminPassword'] = row[4]
            result['adminSalt'] = row[5]
            result['adminDesc'] = row[6]
            result['adminRealName'] = row[7]
            result['adminTelephone'] = row[8]
            result['adminEmail'] = row[9]
            result['adminIsLock'] = row[10]
            result['adminAddTime'] = row[11]

            data.append(result)

        # 使用json.dumps将数据转换为json格式，json.dumps方法默认会输出成这种格式"\u5377\u76ae\u6298\u6263"，
        # 加ensure_ascii=False，则能够防止中文乱码。
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)

        return jsonData

    @staticmethod
    def admin_log_list_to_json(lists):
        """
        把从admin_log表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['userId'] = row[1]
            result['userName'] = row[2]
            result['userIp'] = row[3]
            result['actionType'] = row[4]
            result['logRemark'] = row[5]
            result['logAddTime'] = row[6]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def admin_menu_list_to_json(lists):
        """
        把从admin_menu表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['menuId'] = row[0]
            result['menuParentId'] = row[1]
            result['menuType'] = row[2]
            result['menuTitle'] = row[3]
            result['menuIcoUrl'] = row[4]
            result['menuLinkUrl'] = row[5]
            result['menuSort'] = row[6]
            result['isLock'] = row[7]
            result['remark'] = row[8]
            result['actionKey'] = row[9]
            result['isSys'] = row[10]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def admin_role_list_to_json(lists):
        """
        把从admin_role表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['roleId'] = row[0]
            result['roleName'] = row[1]
            result['roleType'] = row[2]
            result['roleDesc'] = row[3]
            result['roleIsSys'] = row[4]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def admin_role_menu_list_to_json(lists):
        """
        把从admin_role_menu表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['roleMenuId'] = row[0]
            result['roleId'] = row[1]
            result['menuTitle'] = row[2]
            result['actionKey'] = row[3]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def card_list_to_json(lists):
        """
        把从admin_role表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['cardId'] = row[0]
            result['userId'] = row[1]
            result['cardName'] = row[2]
            result['cardPhone'] = row[3]
            result['cardType'] = row[4]
            result['cardCode'] = row[5]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def view_category_items_list_to_json(lists):
        """
        把从admin_role表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['itemId']= row[0]
            result['deptId']= row[1]
            result['itemHandlername']=row[2]
            result['itemHandlerphone']= row[3]
            result['itemTitle']=row[4]
            result['itemPricerange']=row[5]
            result['itemContent']= row[6]
            result['itemUrl']= row[7]
            result['itemDeadline']= row[8]
            result['itemPublishdate']= row[9]
            result['itemAddress']= row[10]
            result['itemStatus']= row[11]
            result['serviceId']= row[12]
            result['itemEnterPerson']= row[13]
            result['itemEnterTime']= row[14]
            result['checkStatusOne']= row[15]
            result['checkRemarkOne']= row[16]
            result['checkPersonOne']= row[17]
            result['checkTimeOne']= row[18]
            result['checkStatusTwo']= row[19]
            result['checkRemarkTwo']= row[20]
            result['checkPersonTwo']= row[21]
            result['checkTimeTwo']= row[22]
            result['id']= row[23]
            result['deptName']= row[24]
            result['deptPcode']= row[25]
            result['deptCode']= row[26]
            result['deptSort']= row[27]
            result['deptAddress']= row[28]
            result['levelCode']= row[29]
            result['provinceId']= row[30]
            result['cityId']= row[31]
            result['districtId'] = row[32]
            result['deptUrl'] = row[33]
            result['desUrl']= row[34]
            result['levelName']= row[35]
            result['provinceName']= row[36]
            result['cityName']= row[37]
            result['districtName']= row[38]
            result['catId']= row[39]
            result['catName']= row[40]
            result['catPcode']= row[41]
            result['catCode']= row[42]
            result['catStatus']= row[43]
            result['catSort']= row[44]
            result['deptIsLock']= row[45]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData


    @staticmethod
    def category_list_to_json(lists):
        """
        把从admin_role表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['catId'] = row[0]
            result['catName'] = row[1]
            result['catPcode'] = row[2]
            result['catCode'] = row[3]
            result['catStatus'] = row[4]
            result['catSort'] = row[5]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def category_dept_list_to_json(lists):
        """
        把从category_dept表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['categoryId'] = row[1]
            result['deptId'] = row[2]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def city_list_to_json(lists):
        """
        把从 city 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['cityId'] = row[0]
            result['cityName'] = row[1]
            result['cityZipcode'] = row[2]
            result['provinceId'] = row[3]
            result['cityCreateTime'] = row[4]
            result['cityUpdateTime'] = row[5]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def coupon_list_to_json(lists):
        """
        把从 coupon 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['couponId'] = row[0]
            result['couponName'] = row[1]
            result['couponDescription'] = row[2]
            result['couponCode'] = row[3]
            result['couponExpirationdate'] = row[4]
            result['couponMemberNums'] = row[5]
            result['couponUsedTimes'] = row[6]
            result['couponType'] = row[7]
            result['couponConditions'] = row[8]
            result['couponDiscount'] = row[9]
            result['couponCreatedPerson'] = row[10]
            result['couponCreatedTime'] = row[11]
            result['couponNeedPoints'] = row[12]
            result['couponIsPoint'] = row[13]
            result['needPrice'] = row[14]
            result['couponTopPrice']=row[15]
            result['couponPercentage']=row[16]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def coupon_view_list_to_json(lists):
        """
        把从 coupon 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['couponName'] = row[0]
            result['couponDescription'] = row[1]
            result['couponCode'] = row[2]
            result['couponExpirationdate'] = row[3]
            result['couponMemberNums'] = row[4]
            result['couponUsedTimes'] = row[5]
            result['couponType'] = row[6]
            result['couponConditions'] = row[7]
            result['couponDiscount'] = row[8]
            result['couponCreatedPerson'] = row[9]
            result['couponCreatedTime'] = row[10]
            result['couponNeedPoints'] = row[11]
            result['couponIsPoint'] = row[12]
            result['needPrice']=[13]
            result['id'] = row[14]
            result['timeUsed'] = row[15]
            result['status'] = row[16]
            result['userName'] = row[17]
            result['memberEmail'] = row[18]
            result['memberName'] = row[19]
            result['userId'] = row[20]
            result['couponId']= row[21]
            result['userPhone']= row[22]
            result['userEmail']= row[23]
            result['userNickName']= row[24]
            result['userStatus']= row[25]
            result['userRegTime']= row[26]
            result['userRegIp']=row[27]
            result['userAvatar']= row[28]


            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def coupon_used_list_to_json(lists):
        """
        把从 coupon_used 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['couponId'] = row[1]
            result['userId'] = row[2]
            result['timesUsed'] = row[3]
            result['status'] = row[4]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def dept_list_to_json(lists):
        """
        把从 coupon 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['deptId'] = row[0]
            result['deptName'] = row[1]
            result['deptPcode'] = row[2]
            result['deptCode'] = row[3]
            result['deptIsLock'] = row[4]
            result['deptSort'] = row[5]
            result['deptAddress'] = row[6]
            result['leveCode'] = row[7]
            result['provinceId'] = row[8]
            result['cityId'] = row[9]
            result['districtId'] = row[10]
            result['deptUrl'] = row[11]
            result['desUrl'] = row[12]
            result['extractFrom'] = row[13]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def district_list_to_json(lists):
        """
        把从 coupon_used 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['districtId'] = row[0]
            result['districtName'] = row[1]
            result['cityId'] = row[2]
            result['districtCreatedTime'] = row[3]
            result['districtUpdatedTime'] = row[4]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def favorite_cart_list_to_json(lists):
        """
        把从 favorite_cart 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['userId'] = row[1]
            result['itemId'] = row[2]
            result['isLock'] = row[3]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def history_list_to_json(lists):
        """
        把从 favorite_cart 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['historyId'] = row[0]
            result['userId'] = row[1]
            result['userIp'] = row[2]
            result['hisKeywords'] = row[3]
            result['hisType'] = row[4]
            result['hisSearchCount'] = row[5]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def hot_list_to_json(lists):
        """
        把从 hot 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['hotName'] = row[1]
            result['hotId'] = row[2]
            result['hotType'] = row[3]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def industry_list_to_json(lists):
        """
        把从 industry 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['indusId'] = row[0]
            result['indusName'] = row[1]
            result['indusPcode'] = row[2]
            result['indusCode'] = row[3]
            result['indusIsLock'] = row[4]
            result['indusSort'] = row[5]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def indus_item_list_to_json(lists):
        """
        把从 hot 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['industryId'] = row[1]
            result['itemId'] = row[2]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def invited_records_list_to_json(lists):
        """
        把从 industry 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['userId'] = row[1]
            result['invitedUserId'] = row[2]
            result['code'] = row[3]
            result['createTime'] = row[4]
            result['isReward'] = row[5]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def invoice_list_to_json(lists):
        """
        把从 industry 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['invoiceId'] = row[0]
            result['userId'] = row[1]
            result['invoiceType'] = row[2]
            result['invoiceContent'] = row[3]
            result['invoiceHeader'] = row[4]
            result['invoiceStatus'] = row[5]
            result['invoiceRemark'] = row[6]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def item_list_to_json(lists):
        """
        把从 item 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['itemId'] = row[0]
            result['deptId'] = row[1]
            result['itemHandlerName'] = row[2]
            result['itemHandlerPhone'] = row[3]
            result['itemTitle'] = row[4]
            result['itemPriceRange'] = row[5]
            result['itemContent'] = row[6]
            result['itemUrl'] = row[7]
            result['itemDeadline'] = row[8]
            result['itemPublishdate'] = row[9]
            result['itemAddress'] = row[10]
            result['itemStatus'] = row[11]
            result['serviceId'] = row[12]
            result['itemEnterPerson'] = row[13]
            result['itemEnterTime'] = row[14]
            result['checkStatusOne'] = row[15]
            result['checkRemarkOne'] = row[16]
            result['checkPersonOne'] = row[17]
            result['checkTimeOne'] = row[18]
            result['checkStatusTwo'] = row[19]
            result['checkRemarkTwo'] = row[20]
            result['checkPersonTwo'] = row[21]
            result['checkTimeTwo'] = row[22]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def item_annc_list_to_json(lists):
        """
        把从 item_annc 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['anncId'] = row[0]
            result['anncTitle'] = row[1]
            result['deptId'] = row[2]
            result['anncPubTime'] = row[3]
            result['anncUrl'] = row[4]
            result['anncStatus'] = row[5]
            result['anncRemark'] = row[6]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def view_area_list_to_json(lists):
        """
        把从 view_area 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['districtName'] = row[0]
            result['districtId'] = row[1]
            result['cityName'] = row[2]
            result['cityZipcode'] = row[3]
            result['cityId'] = row[4]
            result['provinceName'] = row[5]
            result['provinceId'] = row[6]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def view_city_list_to_json(lists):
        """
        把从 view_city 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['cityName'] = row[0]
            result['cityZipcode'] = row[1]
            result['cityId'] = row[2]
            result['provinceName'] = row[3]
            result['provinceId'] = row[4]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def view_item_list_to_json(lists):
        """
        把从 view_item 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['itemId'] = row[0]
            result['itemHandlerName'] = row[1]
            result['itemHandlerPhone'] = row[2]
            result['itemTitle'] = row[3]

            result['itemPriceRange'] = row[4]

            result['itemContent'] = row[5]
            result['itemUrl'] = row[6]
            result['itemDeadline'] = row[7]
            result['itemPublishdate'] = row[8]

            result['itemAddress'] = row[9]

            result['itemStatus'] = row[10]

            result['serviceId'] = row[11]
            result['serviceName'] = row[12]
            result['serviceCode'] = row[13]
            result['servicePrice'] = row[14]

            result['serviceRate'] = row[15]
            result['serviceStatus'] = row[16]
            result['serviceContent'] = row[17]
            result['serviceContract'] = row[18]
            result['serviceStartDate'] = row[19]

            result['serviceEndDate'] = row[20]
            result['deptId'] = row[21]
            result['deptName'] = row[22]
            result['deptPcode'] = row[23]
            result['deptCode'] = row[24]
            result['deptIsLock'] = row[25]

            result['deptSort'] = row[26]
            result['deptAddress'] = row[27]
            result['leveCode'] = row[28]
            result['provinceId'] = row[29]
            result['cityId'] = row[30]

            result['districtId'] = row[31]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def view_role_menu_list_to_json(lists):
        """
        把从 view_role_menu 表查询出的信息转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['roleId'] = row[0]
            result['roleName'] = row[1]
            result['roleType'] = row[2]
            result['roleIsSys'] = row[3]
            result['roleDesc'] = row[4]
            result['id'] = row[5]
            result['menuId'] = row[6]
            result['menuParentId'] = row[7]
            result['menuType'] = row[8]
            result['menuTitle'] = row[9]
            result['menuIcoUrl'] = row[10]
            result['menuLinkUrl'] = row[11]
            result['menuSort'] = row[12]

            result['isLock'] = row[13]
            result['remark'] = row[14]
            result['actionKey'] = row[15]
            result['isSys'] = row[16]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData


class Table2JsonByYM(object):
    """
    以下内容由YM书写

    """

    @staticmethod
    def user_reCharge_list_to_json(lists):
        """
        表名：zzh_user_recharge
        说明：用户充值表
        zzh_user_recharge转换为json格式
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['userId'] = row[1]
            result['userName'] = row[2]
            result['rechargeNumber'] = row[3]
            result['paymentId'] = row[4]
            result['amount'] = row[5]
            result['status'] = row[6]
            result['creatTime'] = row[7]
            result['completeTime'] = row[8]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def user_oauth_list_to_json(lists):
        """
        表名：zzh_user_oauth
        说明：OAuth授权用户信息表
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['userId'] = row[1]
            result['userName'] = row[2]
            result['oauthName'] = row[3]
            result['oauthAccessToken'] = row[4]
            result['oauthOpenId'] = row[5]
            result['addTime'] = row[6]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def user_oauth_app_list_to_json(lists):
        """
        表名：zzh_user_oaurh_app
        说明：OAuth应用表
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['appTitle'] = row[1]
            result['appImgUrl'] = row[2]
            result['appId'] = row[3]
            result['appKey'] = row[4]
            result['remark'] = row[5]
            result['appSort'] = row[6]
            result['appIsLock'] = row[7]
            result['apiPath'] = row[8]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def user_login_log_list_to_json(lists):
        """
        表名：zzh_user_login_log
        说明：用户登录日志表
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['userId'] = row[1]
            result['userName'] = row[2]
            result['loginTime'] = row[3]
            result['loginIp'] = row[4]
            result['remark'] = row[5]
            result['loginType'] = row[6]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def user_group_list_to_json(lists):
        """
        表名：zzh_user_group
        说明：会员组（VIP 跟注册会员）
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['groupName'] = row[1]
            result['groupDes'] = row[2]
            result['groupLogo'] = row[3]
            result['groupStatus'] = row[4]
            result['groupCreateTime'] = row[5]
            result['groupFee'] = row[6]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def user_code_list_to_json(lists):
        """
        表名：zzh_user_code
        说明：用户随机码表
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['userId'] = row[1]
            result['userName'] = row[2]
            result['type'] = row[3]
            result['stringCode'] = row[4]
            result['count'] = row[5]
            result['status'] = row[6]
            result['userIp'] = row[7]
            result['effTime'] = row[8]
            result['creatTime'] = row[9]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def user_list_to_json(lists):
        """
        表名：zzh_user

        说明：登录用户表
        :param lists:
        :return:
        """
        data = []
        for row in lists:
            result = {}
            result['userId'] = row[0]
            result['userName'] = row[1]
            result['userSalt'] = row[2]
            result['userPassword'] = row[3]
            result['userPhone'] = row[4]
            result['userEmail'] = row[5]
            result['userAvatar'] = row[6]
            result['userNickName'] = row[7]
            result['userStatus'] = row[8]
            result['userRegTime'] = row[9]
            result['userRegIp'] = row[10]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def user_amount_log_list_to_json(lists):
        """
        表名：zzh_ueser_amount_log

        说明：会员金额日志表
        :return:
        """

        data = []
        for row in lists:
            result = {}
            result['id'] = row[0]
            result['userId'] = row[1]
            result['userName'] = row[2]
            result['paymentId'] = row[3]
            result['value'] = row[4]
            result['reamrk'] = row[5]
            result['creatTime'] = row[6]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def share_list_to_json(lists):
        """
        表名：zzh_share

        说明：分享表
        """

        data = []
        for row in lists:
            result = {}
            result['shareId'] = row[0]
            result['userId'] = row[1]
            result['userName'] = row[2]
            result['shareContent'] = row[3]
            result['shareAddTime'] = row[4]
            result['sharePrivacy'] = row[5]
            result['shareCommentCount'] = row[6]
            result['shareStatus'] = row[7]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def service_list_to_json(lists):
        """
        表名：zzh_share

        说明：分享表
        """

        data = []
        for row in lists:
            result = {}
            result['serviceId'] = row[0]
            result['serviceName'] = row[1]
            result['serviceCode'] = row[2]
            result['servicePrice'] = row[3]
            result['serviceRate'] = row[4]
            result['serviceStatus'] = row[5]
            result['serviceContent'] = row[6]
            result['serviceContact'] = row[7]
            result['serviceStartDate'] = row[8]
            result['serviceEndDate'] = row[9]

            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def report_car_list_to_json(lists):
        """
        表名：zzh_report_cart

        说明：申报车表
        """

        data = []
        for row in lists:
            result = {}
            result['carId'] = row[0]
            result['itemId'] = row[1]
            result['userId'] = row[2]
            result['carStatus'] = row[3]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def province_car_list_to_json(lists):
        """
        表名：zzh_report_cart

        说明：申报车表
        """

        data = []
        for row in lists:
            result = {}
            result['provinceId'] = row[0]
            result['provinceName'] = row[1]
            result['provinceDateCreated'] = row[2]
            result['provinceDateUpdated'] = row[3]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def LeveL_list_to_json(lists):
        """
        表名：zzh_level
        说明：行政级别表
        """
        data = []
        for row in lists:  # 这个地方本来应该写成LeveL，便于区分
            result = {}
            result['LeveLId'] = row[0]
            result['LeveLName'] = row[1]
            result['LeveLCode'] = row[2]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    @staticmethod
    def member_list_to_json(lists):
        """
        表名：zzh_member
        说明：会员信息表（包含个人和单位）
        """
        data = []
        for row in lists:
            result = {}
            result['memberId'] = row[0]
            result['userId'] = row[1]
            result['invited_code'] = row[2]
            result['member_code'] = row[3]
            result['member_name'] = row[4]

            result['member_email'] = row[5]
            result['member_points'] = row[6]
            result['member_balance'] = row[7]
            result['member_expired'] = row[8]
            result['industry_id'] = row[9]  ######

            result['province_id'] = row[10]
            result['city_id'] = row[11]
            result['district_id'] = row[12]
            result['member_favorite_count'] = row[13]
            result['member_address'] = row[14]

            result['member_busness'] = row[15]
            result['member_type'] = row[16]
            result['sp_knowledge'] = row[17]
            result['sp_revenue'] = row[18]
            result['sp_employee'] = row[19]

            result['sp_industrycode'] = row[20]
            result['tm_industrycode'] = row[21]
            result['tm_deptcode'] = row[22]
            result['tm_level'] = row[23]
            result['register_code'] = row[24]
            result['is_vip'] = row[25]


            data.append(result)

        # 使用json.dumps将数据转换为json格式，json.dumps方法默认会输出成这种格式"\u5377\u76ae\u6298\u6263"，
        # 加ensure_ascii=False，则能够防止中文乱码。
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)

        return jsonData

    @staticmethod
    def order_list_to_json(lists):
        """
        表名：zzh_order
        说明：订单表
        """
        data = []
        for row in lists:
            result = {}
            result['order_id'] = row[0]
            result['order_no'] = row[1]
            result['order_ip'] = row[2]
            result['order_type'] = row[3]
            result['trade_no'] = row[4]

            result['user_id'] = row[5]
            result['user_name'] = row[6]
            result['payment_id'] = row[7]
            result['payment_fee'] = row[8]
            result['payment_status'] = row[9]  ######

            result['payment_time'] = row[10]
            result['order_created_time'] = row[11]
            result['is_invoice'] = row[12]
            result['invoice_title'] = row[13]
            result['invoice_taxes'] = row[14]

            result['payable_amount'] = row[15]
            result['real_amount'] = row[16]
            result['order_amount'] = row[17]
            result['order_point'] = row[18]
            result['is_member'] = row[19]

            result['member_name'] = row[20]
            result['member_email'] = row[21]
            result['member_telephone'] = row[22]
            result['member_province'] = row[23]
            result['member_city'] = row[24]

            result['member_district'] = row[25]
            result['member_address'] = row[26]
            result['is_coupon'] = row[27]
            result['coupon_name'] = row[28]
            result['coupon_code'] = row[29]

            result['coupon_type'] = row[30]
            result['coupon_conditions'] = row[31]
            result['coupon_discount'] = row[32]
            result['service_content'] = row[33]
            result['service_contract'] = row[34]

            result['service_code'] = row[35]
            result['service_name'] = row[36]
            result['service_price'] = row[37]
            result['service_rate'] = row[38]
            result['item_name'] = row[39]

            result['item_content'] = row[40]
            result['item_url'] = row[41]
            result['item_address'] = row[42]
            result['item_publishdate'] = row[43]
            result['item_deadline'] = row[44]

            result['item_handlername'] = row[45]
            result['item_handlerphone'] = row[46]
            result['dept_id'] = row[47]
            result['order_status'] = row[48]
            result['order_product_is_success'] = row[49]
            result['order_message'] = row[50]
	    result['item_id'] = row[51]

            data.append(result)

        # 使用json.dumps将数据转换为json格式，json.dumps方法默认会输出成这种格式"\u5377\u76ae\u6298\u6263"，
        # 加ensure_ascii=False，则能够防止中文乱码。
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)

        return jsonData

    @staticmethod
    def point_item_listto_json(point_item_list):
        data = []

        for row in point_item_list:
            result = {}
            result['point_item_id'] = row[0]
            result['point_item_name'] = row[1]
            result['is_per_day'] = row[2]
            result['point_item_point'] = row[3]
            result['point_item_remark'] = row[4]
            result['point_item_sort'] = row[5]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)

        return jsonData

    @staticmethod
    def point_log_listto_json(point_log_list):
        data = []

        for row in point_log_list:
            result = {}
            result['id'] = row[0]
            result['user_id'] = row[1]
            result['username'] = row[2]
            result['point_item_name'] = row[3]
            result['point_value'] = row[4]
            result['remark'] = row[5]
            result['is_income'] = row[6]
            result['create_time'] = row[7]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)

        return jsonData

    @staticmethod
    def url_manage_listto_json(url_manage_list):
        data = []

        for row in url_manage_list:
            result = {}
            result['id'] = row[0]
            result['level_code'] = row[1]
            result['dept_name'] = row[2]
            result['dept_url'] = row[3]
            result['des_url'] = row[4]
            result['evidence_url'] = row[5]
            result['face_keywords'] = row[6]
            result['opposite_keywords'] = row[7]
            result['check_status'] = row[8]
            result['balance_status'] = row[9]
            result['url_remark'] = row[10]
            result['check_time'] = row[11]
            result['add_time'] = row[12]
            result['province_id'] = row[13]
            result['city_id'] = row[14]
            result['district_id'] = row[15]
            result['extract_from'] = row[16]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)

        return jsonData

    '''
    zzh_order_log表
    订单操作历史表
    '''

    @staticmethod
    def orderLog_list_to_json(dataList):
        data = []
        for row in dataList:
            result = {}
            result['orderLogId'] = row[0]
            result['orderId'] = row[1]
            result['userId'] = row[2]
            result['orderActionCode'] = row[3]
            result['orderActionDate'] = row[4]
            result['orderRemark'] = row[5]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    '''
      zzh_payment表
      支付类型表
      '''

    @staticmethod
    def payment_list_to_json(dataList):
        data = []
        for row in dataList:
            result = {}
            result['paymentId'] = row[0]
            result['paymentName'] = row[1]
            result['paymentImgUrl'] = row[2]
            result['paymentRemark'] = row[3]
            result['paymentType'] = row[4]
            result['paymentPoundageType'] = row[5]
            result['paymentPoundageAmount'] = row[6]
            result['paymentSort'] = row[7]
            result['paymentIsLock'] = row[8]
            result['paymentApiPath'] = row[9]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData

    '''
    zzh_message表
    消息表
    '''
    @staticmethod
    def message_list_to_json(dataList):
        data = []
        for row in dataList:
            result = {}
            result['messageId'] = row[0]
            result['messageType'] = row[1]
            result['postId'] = row[2]
            result['postName'] = row[3]
            result['acceptId'] = row[4]
            result['acceptName'] = row[5]
            result['messageIsRead'] = row[6]
            result['messageTitle'] = row[7]
            result['messageContent'] = row[8]
            result['messagePostTime'] = row[9]
            result['messageReadTime'] = row[10]
            data.append(result)
        jsonData = json.dumps(data, cls=MyJsonEncoder, ensure_ascii=False)
        return jsonData
